package com.lzb.newloan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lzb.newloan.R;
import com.lzb.newloan.pojo.BorrowPersonPojo;

import java.util.ArrayList;

public class InvestRecordPersonAdapter extends BaseAdapter {

	private ArrayList<BorrowPersonPojo> pojo;
	private LayoutInflater mInflater;

	public InvestRecordPersonAdapter(Context context, ArrayList<BorrowPersonPojo> pojo) {
		this.pojo = pojo;
		this.mInflater = LayoutInflater.from(context);
	}

	public void setPojo(ArrayList<BorrowPersonPojo> pojo) {
		this.pojo = pojo;
	}

	public ArrayList<BorrowPersonPojo> getPojo() {
		return pojo;
	}

	/**
	 */
	@Override
	public int getCount() {
		return pojo.size();
	}

	@Override
	public Object getItem(int arg0) {

		return pojo.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int postition, View convertView, ViewGroup arg2) {
		ViewHoler viewHolder = null;
		if (convertView == null) {
			viewHolder = new ViewHoler();
			convertView = mInflater.inflate(R.layout.adapter_invest_record_item, null);
			viewHolder.jk_time = (TextView) convertView
					.findViewById(R.id.jk_time);
			viewHolder.money = (TextView) convertView.findViewById(R.id.money);
			viewHolder.person = (TextView) convertView.findViewById(R.id.person);
            viewHolder.hk_times = (TextView)convertView.findViewById(R.id.hk_times);
            viewHolder.lx = (TextView) convertView.findViewById(R.id.lx);
			viewHolder.hk_txt = (TextView) convertView.findViewById(R.id.hk_txt);
			viewHolder.date = (TextView) convertView.findViewById(R.id.date);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHoler) convertView.getTag();
		}
		BorrowPersonPojo data = pojo.get(postition);
		viewHolder.person.setText("借款人："+data.getUsername());
        viewHolder.money.setText(data.getMoney());
        viewHolder.jk_time.setText(data.getFkTime());
		if(data.getTime().equals("empty")){
			viewHolder.hk_txt.setVisibility(View.INVISIBLE);
		}else {
			viewHolder.hk_times.setText(data.getTime());
            viewHolder.hk_txt.setVisibility(View.VISIBLE);
		}
		viewHolder.date.setText(data.getDay());
		return convertView;
	}

	static class ViewHoler {
		public TextView jk_time,money,person,hk_times,lx,hk_txt,date;
	}

}
